package vcp.client.GUI.mvc.view.effects;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

import javax.swing.JComponent;
import javax.swing.plaf.LayerUI;
import javax.swing.text.JTextComponent;
/**
 * <p> validation layer UI class </p>
 * @author VCP team
 *
 */
public class ValidationLayerUI extends LayerUI <JTextComponent>
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1488296417887899317L;

	private boolean isValid = true;

	@Override
	public void paint ( Graphics g, JComponent c )
	{
		super.paint(g, c);

		if ( this.isValid )
		{
			return;
		}

		Graphics2D g2 = (Graphics2D) g.create();

		// Paint the red X.
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		int w = c.getWidth();
		int h = c.getHeight();
		int s = 13;
		int pad = 4;
		int x = w - pad - s;
		int y = ( h - s ) / 2;
		g2.setPaint(Color.red);
		g2.fillRect(x, y, s + 1, s + 1);
		g2.setPaint(Color.white);
		g2.drawLine(x, y, x + s, y + s);
		g2.drawLine(x, y + s, x + s, y);

		g2.dispose();

	}
	/**
	 * setter
	 * @param valid
	 */
	public void setValid ( boolean valid )
	{
		this.isValid = valid;
	}
}
